<template>
    <div>
        <heads title="详情"></heads>
        <van-tabs v-model:active="active">
            <van-tab title="商品">
                <swiper :list="detailaa.pics"></swiper>
                <p>{{ detailaa.goods_name }}</p>
                <p style="color: red;font-weight: 600;">${{ detailaa.goods_price }}</p>
            </van-tab>
            <van-tab title="详情">
                <div v-html="detailaa.goods_introduce"></div>
            </van-tab>
            <van-tab title="评价">内容 3</van-tab>
        </van-tabs>
    </div>
    <van-action-bar>
        <van-action-bar-icon icon="chat-o" text="客服" dot />
        <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
        <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
        <van-action-bar-button type="warning" text="加入购物车" @click="shopaaa()" />
        <van-action-bar-button type="danger" text="立即购买" />
    </van-action-bar>

</template>

<script setup>
import { ref } from "vue"
import swiper from "@/components/swiper.vue";
import heads from '@/components/head.vue';
import { detailApi } from "@/api/api"
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
let goods_id = ref(route.query.goods_id)
console.log(goods_id.value)

const active = ref(0);


let detailaa = ref('')
const bb = () => {
    detailApi(goods_id.value).then(res => {
        detailaa.value = res.data.message
    })
}
bb()

import { showToast } from 'vant';
import { useCounterStore } from '@/stores/counter'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
const shopaaa = () => {
    store.shopaaCar(detailaa.value)
    showToast('加入成功');
    router.push('/home/shop')
}
</script>

<style lang="scss" scoped></style>